import BaseUtil from '@/BaseUtil';
import { OrderId } from '@/globals/order';
import SelectCommon from 'code/Core/Common/SelectCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 暗言术-噬
 **/
export default class MS_InsinuationBite extends AbilityBase {
    static instance: MS_InsinuationBite;
    constructor(id: string) {
        super(id);
        MS_InsinuationBite.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {}
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        BaseUtil.onTimer(1, (c) => {
            let order = GetUnitCurrentOrder(source);
            if (order != OrderId.Drain) return false;
            let lv = this.getAbilityLevel(source);
            let dmg = 17 * lv + UnitCommon.取法强(source) * (0.5 + 0.3 * lv);
            DamageSystemInstance.applyDarkDamage(target, source, dmg, this.id);
            let es = SelectCommon.getAllyUnitInRangeExcludeCenterUnit(target, 225);
            DamageSystemInstance.applyAoeMagicDamage(es, source, dmg / 2, 'dark', this.id);
            DamageSystemInstance.applyHeal(source, source, dmg, this.id);
            return c < 8;
        });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
